home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / hc / windoid1.sit / Windoid #1.TXT
Encoding:
Text File  |  1988-11-29  |  10.4 KB  |  163 lines  |  [TEXT/MACA]

  1. Welcome...
  2.  
  3. This is the first issue of  Windoid - the newsletter for the Apple HyperCard User╒s Group.  We hope the user group and newsletter will create a forum for information about HyperCard, including tips and techniques in various accessible formats to make your use of HyperCard even more valuable, flexible, and fun.
  4.  
  5. We will bring you articles written by the development team and will make efforts to take your questions and problems directly to the source for an answer.
  6.  
  7. In addition, and most importantly, Windoid will create a forum for the open sharing of stackware and information.  
  8.  
  9. Bill and Dan have shown a remarkable ability to immediately understand the needs, ideas, and suggestions of HyperCard users.   The members of the team have thus been able to assist greatly in shaping HyperCard into what it is today.  The continuing interest in user input gives users a unique opportunity to help shape HyperCard╒s future. 
  10.  
  11. This newsletter provides an opportunity for  its readers to contribute to the continued genesis of HyperCard.  With your assistance we can continue to bring to HyperCard added depth and functionality.  In the back of every issue will be a form for you to keep by your Macintosh¬.  This form will give you the unique opportunity to be able to participate in the continued development of HyperCard.  
  12.  
  13. If you have a bug, suggestion, or comment fill 
  14. out the form and send it to:
  15. AHUG
  16. C/O David Leffler
  17. Apple Computer Inc.
  18. MS 27AQ
  19. 20525 Mariani Blvd.
  20. Cupertino, CA  95014
  21.  
  22.  
  23. Or  copy the form's format and AppleLink¬ it to:
  24. HYPERBUG$
  25. ====================
  26. Ask the Team...
  27.  
  28. The HyperCard test team has consented to provide us with a series of tips and techniques based on frequent user questions.  Please send in your questions and they will try to answer the most consistently asked.
  29.  
  30. How can I create a script that will enable me to double-click an icon button?
  31.  
  32. Consider creating a button script like the following.
  33. The following handler makes a button that will detect a double-click on itself.  It waits 30 ticks for the 2nd click then times out.
  34. Put this handler into a button╒s script, then add whatever special things you want your button to do when double-clicked. Adjust the timeout value if you want it to wait longer (or shorter).   A tick is 1/60th of a second.
  35. on mouseUp
  36.   put the ticks into originalTicks
  37.   repeat until the mouseClick
  38.     if the ticks - originalTicks > 30
  39.      then exit mouseUp
  40.   end repeat
  41.   -- Put here whatever you want the 
  42.   --button to do when double-clicked.
  43.   -- For example:
  44.   Play ╥Boing╙
  45. end mouseUp
  46.  
  47.  
  48. How can I get a word in a field to do something when I click on it?
  49.  
  50. One way would be to put a transparent button over the text.  If you want to be able to move the word around inside the field without having to move the transparent button with it, you can use the following ╥sticky button╙ technique.
  51.  
  52.      The following script gets put into the field:
  53. On Mousedown
  54.     Set locktext of me to false
  55.     click at the clickloc
  56.     click at the clickloc
  57.     if the selection is ╥Apple╙ then
  58.         answer ╥What kind of Apple:╙ with
  59.         ╥Macintosh╙ or ╥Apple II╙
  60.     else
  61.         put ╥I don╒t know that word╙ 
  62.         into msg
  63.     end if
  64.     set locktext of me to true
  65. End Mousedown
  66.  
  67. Note: MouseDown, mouseStillDown, and mouseUp messages only get sent to a field when that field is locked. It is therefore necessary to lock a field when expecting that field to deal with any of these messages.
  68.  
  69. The idea behind sticky buttons is to cause a word to be selected (highlighted) with a single mouse click. ╘The selection╒ then becomes a container.
  70.  
  71. In the above script, we first unlock the field so that we can create a selection. Next, we want to make Hypercard believe that we have double clicked a word, when we really have clicked it only once. This is done in the next two lines of the script. Clicking at the clickloc forces Hypercard to click twice at the same location clicked at by the user. A highlighted selection is then created. Once a word is highlighted, we can use the Hypercard function ╘the selection╒ to find out what that word is. 
  72.  
  73. Comparison can be done using multiple IF THEN statements or by the use of a word-list field. In the above script, we do a very simple IF THEN ELSE comparison which only looks for the word APPLE. When found, it puts up a dialog. If any other word is clicked, a generic message is placed in the message box. Remember that you do not need to show the message box every time you want to write into it. Hypercard displays the message box automatically whenever text is placed inside it.
  74.  
  75. How can I find out which line of a field a user has clicked in?
  76.  
  77. It is easy to calculate using information that can be obtained about a given field. 
  78.  
  79. First of all, we can find out what size rectangle a field occupies by using the field property, RECT. Short for rectangle, RECT returns four numbers in a comma separated list. The numbers represent the upper-left and lower-right screen coordinates for that field.
  80. Next, we can find out what the line height of each line of a field is by using the field property, TEXTHEIGHT. As you might have guessed, each line of a field can really be expressed as a multipleof the line height. Unfortunately, we must determine that multiple using the screen coordinates. Here╒s a user defined function that will do just that:
  81. Function Clickline
  82.     return ((item 2 of the 
  83.     clickloc - item 2 of the rect of the
  84.     target) div the textheight of the
  85.     target) + 1
  86. End Clickline
  87.  
  88. on openField
  89.     put clickline() into msg
  90.     pass openField
  91. end openField
  92.  
  93. Ignore the openField handler for now, but take a look at the function. As you may remember, the Hypercard function, THE TARGET, returns the name and id of the object which last received a message. Likewise, the Hypercard function THE CLICKLOC returns the horizontal and vertical screen position of the last mouse click as two comma separated integers. With that knowledge, let╒s dissect the function Clickline() (yes, you need the parentheses).
  94.  
  95. The function returns an integer which represents the number of the line of any field clicked in. 
  96.  
  97. Here╒s how the function determines the field╒s line number. First, it takes the vertical location clicked at by the user (item 2 of the clickloc) and subtracts the top of the field (item 2 of the rect) to determine how many pixels are between the top of the field and the location clicked at. Once this is known, determining the line number is a matter of dividing those pixels by the TEXTHEIGHT. This is what the rest of the function does. We add 1 because Clickline() returns a zero for line 1.
  98.  
  99. Clickline() is very flexible. In the openfield handler shown above for example, we use clickline() with a put statement, treating it just like the number it returns. You can also use it with an IF THEN statement or any place where you would use the number itself. All you need do is replace the ╘put line╒ of the openfield handler with your script.
  100. What about scrolling fields?
  101.  
  102. An interesting exception arises when using scrolling fields. The above function does not account for lines that may have scrolled off of the screen. It looks only at the visible area of the field. Consider the following function:
  103.  
  104. Function Clickline
  105.     return (((item 2 of the 
  106.     clickloc - item 2 of the rect of the
  107.     target) div the textheight of the
  108.     target) + 1 + trunc(scroll of the
  109.     target/textheight of the target))
  110. End Clickline
  111.  
  112. It adds the number of lines that have scrolled off the screen to the total number of visible lines. The field property SCROLL returns the number of pixels scrolled off the top of the field. When divided by the TEXTHEIGHT, this yields the number of lines. Since a full line may not have scrolled by, it is necessary to truncate the value using the TRUNC function.
  113.  
  114. Put both the function definition and the openfield handler in your home script where they can be used by any field in any stack.
  115.  
  116. How can I hide buttons from command-option key peek?
  117.  
  118. When you don╒t want people peeking at your buttons, it is necessary to trap the command and option keys. While there are several ways of doing this, here is one that is simple and works about 99% of the time.
  119.  
  120. The basic idea is to take the user to another card when the command and option keys are both pressed. This can be a ╥no peeking╙ card or a rules card or some other kind of card. When the user releases both keys, you then return to the card the user was viewing before trying to peek. Following are the two scripts that accomplish this. Put the top one in your  stack script and the other in the ╥no peeking╙ card script.
  121. For the stack script:
  122. On Idle
  123.     if the commandkey is down and 
  124.     the optionkey is down then
  125.         push this card
  126.         go card ╥no peeking╙
  127.     end if
  128. end Idle
  129.  
  130. For the ╥no peeking╙ card script:
  131. On Idle
  132.     if the commankey is up and 
  133.     the optionkey is up then
  134.         pop card
  135.     end if
  136. End Idle
  137. ====================
  138. Stack Building Hints
  139. Beware of relying entirely on  ╥Go Back╙  buttons for navigation through your stack.    A good technique is: On openCard  ╥push recent card╙, which remembers where you just came from.  Then when you do a ╥pop card╙ you will always go to that recent location.  
  140.  
  141. If you suspect that your pushes and pops are not in sync,  add the following handlers to your stack script to help you sort them out.
  142.  
  143. on pop params
  144.     put the params after msg
  145.     pass pop   
  146. end pop
  147.  
  148. on push params
  149.     put the params after msg
  150.     pass push
  151. end push
  152. ====================
  153.  
  154. Power User Tips
  155. Ñ  Create a button on your Home card with a script that says, 'go to stack "the stack you want╙.'  When you click on it, not finding a stack by that name it will put up SFGetfile asking ╥Where is the stack you want?╙ 
  156. Ñ  To zoom directly to the script of an object, hold down the Shift key while double clicking on the object, or while choosing Object "Info...".
  157. Ñ  Do not name a button or a field with a name that begins with a numeric character.  This causes problems in that  if you ask for a button ╥1812╙ HyperCard looks for the button whose number, not name, is 1812.
  158. Ñ  In the button or field tools, holding the shift key down when dragging constrains the movement horizontally or vertically, making it easy to drag in a straight line.
  159. Ñ  With any tool, Option-Drag in Fatbits allows you to scroll the screen.
  160. Ñ  To ╥pre warm╙ the cards in a stack so that ╥show all cards╙ will really cook through the stack, put an "on openStack" script that locks the screen, shows all cards, and then unlocks the screen.  This quickly and invisibly caches all the cards, so that "show card" scripts will work at optimum speed.
  161. Ñ  If you are running on a Mac II and want to see Visual Effects, be sure to set the monitor to 2 bit mode.
  162.  
  163.